|
ARD2
RC2
Airbag Reference Demonstrator using MPC5604P
|
00001 00016 #include "derivative.h" 00017 #include "FCU.h" 00018 /* 00019 ****************************************************************************** 00020 * Constants 00021 ****************************************************************************** 00022 */ 00023 /* 00024 ****************************************************************************** 00025 * Globals 00026 ****************************************************************************** 00027 */ 00028 /* 00029 ****************************************************************************** 00030 * u8fnFCUInit 00031 ****************************************************************************** 00032 */ 00033 uint8_t u8fnFCUInit(FCUConfig_t* ptMyConfig) 00034 { 00035 uint8_t u8Status; 00036 00037 u8Status = FCU_LOCKED; 00038 00039 /* Configuration is only possible once before lock. Check this is the case */ 00040 if(FCU_IS_IN_INIT == u8fnFCUSMStatus()) 00041 { 00042 /* Continue with the configuration */ 00043 /* Start with MCR */ 00044 /* Configure Test Mode */ 00045 FCU.MCR.B.TM = ptMyConfig->P.TM; 00046 /* Configure pin polarity */ 00047 FCU.MCR.B.PS = ptMyConfig->P.PS; 00048 /* Configure pin behavior */ 00049 FCU.MCR.B.FOM = ptMyConfig->P.FOM; 00050 /* Configure pre-scaler */ 00051 FCU.MCR.B.FOP = ptMyConfig->P.FOP; 00052 /* Continue with Alarm time-out */ 00053 FCU.TR.R = ptMyConfig->P.Timeout; 00054 /* Next, configure hardware enablement */ 00055 FCU.FER.R = (uint32_t)ptMyConfig->P.HardwareEnable; 00056 /* And do the same for software */ 00057 FCU.FER.B.ESF0 = ptMyConfig->P.ESF0; 00058 FCU.FER.B.ESF1 = ptMyConfig->P.ESF1; 00059 FCU.FER.B.ESF2 = ptMyConfig->P.ESF2; 00060 FCU.FER.B.ESF3 = ptMyConfig->P.ESF3; 00061 FCU.FER.B.ESF4 = ptMyConfig->P.ESF4; 00062 /* Now configure if we're going into alarm mode or directly error mode */ 00063 /* in case a fault is found. */ 00064 FCU.TER.R = (uint32_t)ptMyConfig->P.TEH; 00065 FCU.TER.B.TESF0 = ptMyConfig->P.TES0; 00066 FCU.TER.B.TESF1 = ptMyConfig->P.TES1; 00067 FCU.TER.B.TESF2 = ptMyConfig->P.TES2; 00068 FCU.TER.B.TESF3 = ptMyConfig->P.TES3; 00069 FCU.TER.B.TESF4 = ptMyConfig->P.TES4; 00070 00071 /* Clear Status */ 00072 u8Status = CLEAR; 00073 } 00074 else 00075 { 00076 /* Out we go */ 00077 } 00078 00079 return(u8Status); 00080 } 00081 /* 00082 ****************************************************************************** 00083 * u8fnFCUInit 00084 ****************************************************************************** 00085 */ 00086 uint8_t u8fnFCUEnableConfig(void) 00087 { 00088 uint8_t u8Status; 00089 00090 u8Status = FCU_LOCKED; 00091 if(FCU_IS_IN_INIT == u8fnFCUSMStatus()) 00092 { 00093 /* Lock configuration and enable FCU */ 00094 FCU.MCR.B.MCL = TRUE; 00095 u8Status = CLEAR; 00096 } 00097 else 00098 { 00099 /* Done */ 00100 } 00101 00102 return(u8Status); 00103 } 00104 /* 00105 ****************************************************************************** 00106 * u8fnFCUStatus 00107 ****************************************************************************** 00108 */ 00109 uint8_t u8fnFCUSMStatus(void) 00110 { 00111 return((uint8_t)FCU.MSR.R); 00112 } 00113 /* 00114 ****************************************************************************** 00115 * 00116 * End of file. 00117 * 00118 ****************************************************************************** 00119 */